import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'
import { HttpExceptionFilter } from './exception/http-exception.filter'

async function bootstrap() {
  const app = await NestFactory.create(AppModule)
  // 允许跨域
  app.enableCors()
  // 绑定异常过滤器
  app.useGlobalFilters(new HttpExceptionFilter());

  // Swagger相关
  const options = new DocumentBuilder()
    .setTitle('番茄后端接口文档')
    .setDescription('此文档使用Swagger自动生成')
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api', app, document);
  await app.listen(3000)
}
bootstrap()
